.\"***************************************************************************
.\" Copyright 2018-2024,2025 Thomas E. Dickey                                *
.\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
.\"                                                                          *
.\" Permission is hereby granted, free of charge, to any person obtaining a  *
.\" copy of this software and associated documentation files (the            *
.\" "Software"), to deal in the Software without restriction, including      *
.\" without limitation the rights to use, copy, modify, merge, publish,      *
.\" distribute, distribute with modifications, sublicense, and/or sell       *
.\" copies of the Software, and to permit persons to whom the Software is    *
.\" furnished to do so, subject to the following conditions:                 *
.\"                                                                          *
.\" The above copyright notice and this permission notice shall be included  *
.\" in all copies or substantial portions of the Software.                   *
.\"                                                                          *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
.\"                                                                          *
.\" Except as contained in this notice, the name(s) of the above copyright   *
.\" holders shall not be used in advertising or otherwise to promote the     *
.\" sale, use or other dealings in this Software without prior written       *
.\" authorization.                                                           *
.\"***************************************************************************
.\"
.\" $Id: curs_border.3x,v 1.63 2025/02/02 00:00:33 tom Exp $
.TH curs_border 3X 2025-02-01 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
.ie \n(.g \{\
.ds `` \(lq
.ds '' \(rq
.\}
.el \{\
.ie t .ds `` ``
.el   .ds `` ""
.ie t .ds '' ''
.el   .ds '' ""
.\}
.
.de bP
.ie n  .IP \(bu 4
.el    .IP \(bu 2
..
.SH NAME
\fB\%border\fP,
\fB\%wborder\fP,
\fB\%box\fP,
\fB\%hline\fP,
\fB\%whline\fP,
\fB\%vline\fP,
\fB\%wvline\fP,
\fB\%mvhline\fP,
\fB\%mvwhline\fP,
\fB\%mvvline\fP,
\fB\%mvwvline\fP \-
draw borders and lines in a \fIcurses\fR window of characters
.SH SYNOPSIS
.nf
\fB#include <curses.h>
.PP
\fBint border(chtype \fIls\fP, chtype \fIrs\fP, chtype \fIts\fP, chtype \fIbs\fP,
      \fBchtype \fItl\fB, chtype \fItr\fB, chtype \fIbl\fB, chtype \fIbr\fB);\fR
\fBint wborder(WINDOW *\fIwin\fB, chtype \fIls\fB, chtype \fIrs\fB,\fR
      \fBchtype \fIts\fB, chtype \fIbs\fB, chtype \fItl\fB, chtype \fItr\fB,\fR
      \fBchtype \fIbl\fB, chtype \fIbr\fB);\fR
.PP
\fBint box(WINDOW *\fIwin\fB, chtype \fIverch\fB, chtype \fIhorch\fB);\fR
.PP
\fBint hline(chtype \fIch\fB, int \fIn\fB);\fR
\fBint whline(WINDOW *\fIwin\fB, chtype \fIch\fB, int \fIn\fB);\fR
\fBint mvhline(int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
\fBint mvwhline(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
.PP
\fBint vline(chtype \fIch\fB, int \fIn\fB);\fR
\fBint wvline(WINDOW *\fIwin\fB, chtype \fIch\fB, int \fIn\fB);\fR
\fBint mvvline(int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
\fBint mvwvline(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
.fi
.SH DESCRIPTION
.B \%wborder
and
.B \%border
draw a box at the edges of the specified window or
.BR \%stdscr ","
respectively.
Each
.I \%chtype
argument corresponds to a geometric component of the border as follows:
.RS
.I ls
\- left side,
.br
.I rs
\- right side,
.br
.I ts
\- top side,
.br
.I bs
\- bottom side,
.br
.I tl
\- top left-hand corner,
.br
.I tr
\- top right-hand corner,
.br
.I bl
\- bottom left-hand corner, and
.br
.I br
\- bottom right-hand corner.
.RE
.PP
If any
.I \%chtype
argument is
.BR 0 ","
then
.I curses
uses forms-drawing characters
(see \fBaddch\fP(3X))
in the following correspondence:
.RS
.BR \%ACS_VLINE ","
.br
.BR \%ACS_VLINE ","
.br
.BR \%ACS_HLINE ","
.br
.BR \%ACS_HLINE ","
.br
.BR \%ACS_ULCORNER ","
.br
.BR \%ACS_URCORNER ","
.br
.BR \%ACS_LLCORNER ","
and
.br
.BR \%ACS_LRCORNER "."
.RE
.PP
.BI \%box( win ","
.IB verch ,
.IB horch )
is shorthand for
.RB \%\*(`` wborder(\c
.IB win ,
.IB verch ,
.IB horch ,
.BR "0, 0, 0, 0)" "\*(''."
.PP
.B \%whline
draws a horizontal line of
.I ch
from left to right,
and
.B \%wvline
a vertical one from top to bottom,
stopping once
.I n
characters have been drawn or upon reaching the boundary of
.IR win "."
These functions do not update the cursor position
(beyond any motion directed by their \*(``mv\*('' variants).
\fB\%ncurses\fP(3X) describes the variants of these functions.
.SH RETURN VALUE
These functions return
.B OK
on success and
.B ERR
on failure.
.PP
In
.IR \%ncurses ","
.bP
these functions fail if the screen is not initialized;
and
.bP
functions taking a
.I \%WINDOW
pointer argument fail if
.I win
is a null pointer.
.PP
Functions prefixed with \*(``mv\*('' first perform cursor movement and
fail if the position
.RI ( y ,
.IR x )
is outside the window boundaries.
.SH NOTES
Unusually,
there is no
.B \%wbox
function;
.B \%box
behaves as one would expect
.B \%wbox
to,
accepting a
.I \%WINDOW
pointer argument.
.PP
.BR \%border ","
.BR \%box ","
.BR \%hline ","
.BR \%mvhline ","
.BR \%mvwhline ","
.BR \%vline ","
.BR \%mvvline ","
and
.B \%mvwvline
may be implemented as macros.
.PP
Borders drawn by these functions are
.I interior
borders.
.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/libcurses/box.c
.SH PORTABILITY
These functions are described in X/Open Curses Issue\ 4.
It specifies no error conditions for them.
.PP
SVr4 documentation
.\" SVID 4, vol. 3, p. 483
says that these functions return
.I OK
\*(``or a non-negative integer if
.I \%immedok() \" Courier roman in source
is set\*('',
referring to the return value from
.IR \%wrefresh ","
which in SVr4 returns a count of characters
written to the window if its
.I \%immedok
property is set;
.\" ...though its wrefresh() man page says nothing about immedok()...
in
.IR \%ncurses ","
it does not.
.PP
BSD
.I curses
drew boxes with
.I horch
in
.I every
character cell of the top and bottom lines of the window,
whereas SVr3.1 and later
.IR curses ","
because its
.I box
wrapped
.IR wborder ","
used the default corner characters.
.\" https://github.com/ryanwoodsmall/oldsysv/blob/master/sysvr3/31/\
.\"   usr/src/lib/libcurses/screen/curses.ed#L454
.SH HISTORY
4BSD (1980)
introduced
.IR box ","
defining it as a function.
.PP
SVr3.1 (1987)
added
.I \%whline
and
.I \%wvline
and their variants,
as well as
.I \%border
and
.IR \%wborder ","
redefining
.I \%box
as a macro wrapping the latter.
.SH SEE ALSO
\fB\%curses\fP(3X),
\fB\%curs_outopts\fP(3X)
